import 'package:custom_widgets/item_normal_widget.dart';
import 'package:flutter/material.dart';
import 'package:flutter_ui_demo/utils/toast_util.dart';

class BotToastPage extends StatefulWidget {
  @override
  _BotToastPageState createState() => _BotToastPageState();
}

class _BotToastPageState extends State<BotToastPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("测试BotToast"),
        centerTitle: true,
        elevation: 0.0,
      ),
      body: _buildBody(),
    );
  }

  Widget _buildBody() {
    return ListView(
      children: <Widget>[
        ItemNormalWidget.item(
          title: "BotToast(showMessage))",
          onTap: () {
            Toast.showMessage("showMessage");
          },
        ),
        ItemNormalWidget.item(
          title: "BotToast(showSuccess))",
          onTap: () {
            Toast.showSuccess("showSuccess");
          },
        ),
        ItemNormalWidget.item(
          title: "BotToast(showInfo))",
          onTap: () {
            Toast.showInfo("showInfo");
          },
        ),
        ItemNormalWidget.item(
          title: "BotToast(showWarn))",
          onTap: () {
            Toast.showWarn("showWarn");
          },
        ),
        ItemNormalWidget.item(
          title: "BotToast(showError))",
          onTap: () {
            Toast.showError("showError");
          },
        ),
        ItemNormalWidget.item(
          title: "BotToast(showLoading))",
          onTap: () {
            Toast.showLoading(
                loadingMsg: "加载中...", duration: Duration(seconds: 2));
          },
        ),
        ItemNormalWidget.item(
          title: "BotToast(showNotification))",
          onTap: () {
            Toast.showNotification(
              leading: Icon(Icons.access_alarm),
              title: "showNotification",
              subTitle: "subTitle",
              closeIcon: Icon(Icons.close),
              duration: Duration(seconds: 10),
            );
          },
        ),
      ],
    );
  }
}
